//
//  BackView.m
//  代理端
//
//  Created by mac on 16/3/4.
//  Copyright © 2016年 sliver. All rights reserved.
//

#import "BackView.h"
#import "AlterView.h"
@interface BackView()<AlterViewDeleget>
@property(nonatomic,strong)AlterView *alterview;
@end
@implementation BackView 

//-(instancetype)init
//{
//    if (self = [super init]) {
//        [self setupUi];
//    }
//    return self;
//}
-(void)setupUi:(NSInteger )count
{
    self.backgroundColor = rgb(0, 0, 0, 0.2);
    
    self.alterview =(AlterView *)[AlterView viewFormXib:@"AlterView"];
    
    self.alterview.frame = CGRectMake((ScreenW-210)/2, (ScreenH-183)/2, 210, 183);
    
    [self.alterview setwitchbtnCount:count];
    
    self.alterview.deleget = self;
    
    [self addSubview:self.alterview];

}
-(void)WitchBtnClic:(UIButton *)butten WithMessae:(NSString *)message
{
        if ([self.deleget respondsToSelector:@selector(makeSureButtenClic: withMessage:)]) {
            [self.deleget makeSureButtenClic:butten withMessage:message];
            [self removeFromSuperview];
        }else
        {
            [self removeFromSuperview];
        }
    
}

-(void)addToview:(UIView *)view WithDeleget:(id)deleget WithMessage:(NSString *)message WithBtnCount:(NSInteger)count;
{
    [self setupUi:count];

    [view addSubview:self];
    
    self.frame = view.frame;
    
    self.deleget = deleget;
    [self.alterview setMessage:message];
    
}
+(void)addToview:(UIView *)view WithDeleget:(id)deleget WithMessage:(NSString *)message WithBtnCount:(NSInteger)count;
{
    
    BackView *view2 = [[BackView alloc]init];
    
    [view2 addToview:view WithDeleget:deleget WithMessage:message WithBtnCount:count];
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    [self removeFromSuperview];
}
-(void)changetitle:(NSString *)left righttitle:(NSString *)right
{
    
    [self.alterview changetitle:left righttitle:right];
}

@end
